﻿<!--
    /// This file uses a graphing control from Codeplex (DynamicDataDisplay). 
/// As per the Licensing terms of DynamicDataDisplay this file is under the license Microsoft Reciprocal License (Ms-RL)
/// 
/// Microsoft Reciprocal License (Ms-RL)

/// This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

/// 1. Definitions

/// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

/// A "contribution" is the original software, or any additions or changes to the software.

/// A "contributor" is any person that distributes its contribution under this license.

/// "Licensed patents" are a contributor's patent claims that read directly on its contribution.

/// 2. Grant of Rights

/// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

/// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

/// 3. Conditions and Limitations

/// (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. You may license other files that are entirely your own work and do not contain code from the software under any terms you choose.

/// (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

/// (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

/// (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

/// (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

/// (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 
    -->
    
    <Window x:Class="MindTree.PerfWorkbench.Azure.Monitor.AzureMonitor.AzureMonStudio"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="http://research.microsoft.com/DynamicDataDisplay/1.0"
    xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:src="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.AzureMonitor"
    xmlns:local="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor"
    xmlns:commandlib="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.CommandLib;assembly=AzureCommandLib"
    xmlns:core="clr-namespace:MindTree.PerfWorkbench.Azure.Monitor.Core;assembly=Core"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="Cloud Monitoring Studio" Width="975" Height="750" AllowsTransparency="False" Name="CMSMainWindow" Loaded="CMSMainWindow_Loaded">
    <Window.Resources>
        <DataTemplate  x:Key="GraphTemplate">
            <StackPanel>
                <c:ChartPlotter Name="GraphPlotter" Height="60" Width="60">
                    <c:Header Content="CustomGraph" />
                    <c:ChartPlotter.HorizontalAxis>
                        <c:HorizontalDateTimeAxis Name="dateAxis"/>                        
                    </c:ChartPlotter.HorizontalAxis>
                </c:ChartPlotter>
                <Button Name="AddCntr"></Button>
                <Button Name="RemoveCntr"></Button>
                <Button Name="AddRole"></Button>
                <Button Name="RemoveRole"></Button>
                
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

    <Grid x:Name="LayoutBase" Background="MidnightBlue">
            <Grid.Resources>
            <LinearGradientBrush 
                x:Key="TreeViewItemBackground"  
                EndPoint="1,0.5" 
                StartPoint="0,0.5">
                
                <GradientStop Color="#FFA6CAEC" Offset="0"/>
                <GradientStop Color="#FFAFD0EE" Offset="1"/>
                <GradientStop Color="#FFE4EFF8" Offset="0.498"/>
            
            </LinearGradientBrush>

            <!-- Application Header Templates -->
            <DataTemplate x:Key="ApplicationHeaderTemplate" DataType="{x:Type core:AzureAppDeployment}">
                <StackPanel Orientation="Horizontal" Width="Auto">
                    <TextBlock Text="{Binding Path=FullName}" />
                </StackPanel>
            </DataTemplate>

            <!-- Role Header Template -->
            <DataTemplate x:Key="RoleHeaderTemplate" DataType="{x:Type core:AzureRole}">
                <StackPanel Orientation="Horizontal" Width="Auto">
                    <TextBlock Text="{Binding RoleName}" />
                </StackPanel>
            </DataTemplate>

                <!-- Role Instance Header Template -->
            <DataTemplate x:Key="RoleInstanceHeaderTemplate" DataType="{x:Type core:AzureRoleInstance}">
                <StackPanel Orientation="Horizontal" Width="Auto">
                    <TextBlock Text="RoleInstance" />
                </StackPanel>
            </DataTemplate>
                
            <DataTemplate x:Key="RoleInstanceTemplate">
                <Border BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10"
                        Background="{StaticResource TreeViewItemBackground}" >
                    
                        <Grid Margin="5,5,5,5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="{Binding Path=RoleInstanceId}" 
                                       Grid.Column="0" Grid.Row="0" />                            
                        </Grid>
                </Border>
            </DataTemplate>    
                
            <!-- Role Content Template-->
            <HierarchicalDataTemplate x:Key="RoleTemplate"
                                       ItemsSource="{Binding Instances}"
                                      ItemTemplate="{StaticResource RoleInstanceTemplate}"    >
                
                <Border BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10"
                        Background="{StaticResource TreeViewItemBackground}" >
                    
                        <Grid Margin="5,5,5,5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                             <TextBlock Text="{Binding Path=RoleName}" 
                                       Grid.Column="0" Grid.Row="0" />
                        </Grid>
                </Border>
            </HierarchicalDataTemplate>

            <!-- Application Content Template -->
            <HierarchicalDataTemplate x:Key="ApplicationTemplate"
                                      ItemsSource="{Binding Roles}"
                                      ItemTemplate="{StaticResource RoleTemplate}">
                <Border x:Name="ApplicationTemplateBorder" BorderBrush="AliceBlue" 
                        BorderThickness="1" CornerRadius="10"
                        Background="{StaticResource TreeViewItemBackground}" >
                
                        <Grid Margin="5,5,5,5">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0" Text="AzureApplication" />                            
                        </Grid>
                </Border>
            </HierarchicalDataTemplate>
            </Grid.Resources>
            <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <!--<RowDefinition Height="Auto" />-->
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border x:Name="MenuBorder" CornerRadius="4" Background="MidnightBlue" Margin="4,2.5,5,0" Height="29">
            
                <ToolBar Height="24" Name="AzureMonToolBar"  Margin="0,0.5,5,0" >

                <Button Height="20" Width="35" >
                        <Image Source="icons\globe_32.png" Height="15" Width="22" ToolTip="Connect to Azure application" MouseDown="Connect_MouseDown" Focusable="True" />
                    </Button>
                <Button Height="20" Width="35" >
                    <Image Source="icons\clipboard_48.png" Height="15" Width="22" ToolTip="Configure Monitoring" MouseDown="Configure_MouseDown"/>
                </Button>
                    
                <Button Height="20" Width="35" >
                        <Image Source="icons\statistics_48.png" Height="15" Width="22" ToolTip="Start Monitoring" MouseDown="Start_MouseDown"/>
                    </Button>
                    
                <GroupBox Margin="0,-1,0,-2">
                    <DockPanel Margin="0,0,0,-3">
                        <CheckBox Name="chkExport" DockPanel.Dock="Left" Margin="0,4,0,-2" ToolTip="Start exporting monitoring results to CSV file from current time" Checked="chkExport_Checked" Unchecked="chkExport_UnChecked"  IsChecked="{Binding Path=IsExportChecked}"></CheckBox>
                    <Label Content="Start Export" FontSize="10" Margin="0,0,0,-4" ToolTip="Start exporting monitoring results to CSV file from current time">                        
                    </Label>
                        
                    </DockPanel>
                </GroupBox>
                <Button Height="20" Width="35" >
                    <Image Source="icons\help-13.png" Height="18" Width="26" ToolTip="About" MouseDown="About_MouseDown"/>
                </Button>
            </ToolBar>


           <!-- </ToolBarPanel> -->
        </Border>
        <Grid Grid.Row="1" Name="GridPerfMon">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="315"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="3*"/>
            </Grid.ColumnDefinitions>            
            <Border CornerRadius="4" 
                    Background="Azure" 
                    
                    MinWidth="200" 
                    Margin="4,4,69,-10" Width="242">
                <!--HorizontalAlignment="Stretch"-->
                <Grid Margin="0,0,0,0"  >
                    
<!--<Grid Margin="0,0,0,0"  Width="256" Height="634">-->
                    <local:AzureAppTreeViewControl x:Name="RolesViewControl" Margin="-3,1,1,0" >                        
                    </local:AzureAppTreeViewControl>
                </Grid>
            </Border>
            <Border Grid.Column="2" 
                    CornerRadius="4" 
                    Background="Azure" 
                    HorizontalAlignment="Stretch" 
                    MinWidth="200" 
                    Margin="-65,4,6,-10">
                <Grid  Grid.RowSpan="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="264*" />
                        <ColumnDefinition Width="247*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="21*" />
                        <RowDefinition Height="492*" />
                    </Grid.RowDefinitions>
                    
                    <TabControl Margin="2,2,2,2" 
                        Name="tabControl1"                        
                        Grid.ColumnSpan="2" Grid.RowSpan="2" >
                        <TabItem Header="PerfMonView" Name="perfMonView" Grid.RowSpan="2">
                            <Grid Name="PerfMonViewGrid">
                                <Border Grid.Column="2" 
                                CornerRadius="4" 
                                Background="Black" 
                                HorizontalAlignment="Stretch" 
                                MinWidth="200" 
                                Margin="0,0,0,0" Name="PerfMonViewBorder">
                                    <c:ChartPlotter Name="plotter" Margin="4,4,4,4" >
                                        <c:Header Content="Azure Performance Monitor View" FontSize="15" Foreground="Brown" />
                                        <c:ChartPlotter.HorizontalAxis>
                                            <c:HorizontalDateTimeAxis Name="dateAxis"/>                                           
                                        </c:ChartPlotter.HorizontalAxis>
                                        
                                    </c:ChartPlotter>                                    
                                </Border>
                                <Image Source="icons\diagram_48.png" ToolTip="Configure PerfMon Graph Counters" MouseDown="AddCounterToGraph" Margin="9,0,633,4" VerticalAlignment="Bottom" MaxHeight="45" MaxWidth="50"/>
                            </Grid>                            
                        </TabItem>
                        <TabItem Header="CustomView" Name="customView" Grid.RowSpan="2">
                            <Grid Name="CustomViewGrid" Margin="0,0,0,0" >
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="29"/>
                                    <RowDefinition Height="Auto" MinHeight="900"/>
                                </Grid.RowDefinitions>
                                <ToolBar Height="27" Name="GraphCustomViewToolbar"  HorizontalAlignment="Left" Grid.Row="0" >
                                    <Button Height="20" Width="35" >
                                        <Image Source="icons\plus_48.png" Height="16" Width="22" ToolTip="Add a new Role Instance Graph" MouseDown="Add_RoleInstance_Graph_Click" />
                                    </Button>
                                </ToolBar>
                                <Border CornerRadius="4" 
                                Background="White" 
                                HorizontalAlignment="Stretch" 
                                MinWidth="200" 
                                MinHeight="200"
                                Margin="0,0,0,0" Name="CustomViewBorder" Grid.Row="1">
                                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Margin="0,2,10,14" >
                                        <WrapPanel Name="CustomViewStackPanel" Margin="8,2,13,13" Orientation="Horizontal" ></WrapPanel>
                                    </ScrollViewer>
                                </Border>
                                
                            </Grid>
                        </TabItem>
                    </TabControl>
                </Grid>
            </Border>            
        </Grid>
        <Border Grid.Row="2" 
                x:Name="StatusBorder" 
                CornerRadius="4" 
                Background="LightSeaGreen" 
                Margin="8,5,8,8" ></Border>
    </Grid>
</Window>

